{% extends 'TopxiaWebBundle:Group:layout.html.twig' %}
{% set script_controller = 'group/group_member' %}
{% block title %}{{groupinfo.title}}小组 - {{ parent() }}{% endblock %}
{% set groupNav = 'member' %}
{% block group_body %}
  {{ web_macro.flash_messages() }}
  <div class="panel panel-default">
    <div class="panel-body">
      <ul class="nav nav-tabs">
        <li {% if groupNav=="index" %}class="active"{% endif %}><a href="{{path('group_show',{id:groupinfo.id})}}">小组首页</a></li>
        <li {% if groupNav=="member" %}class="active"{% endif %}><a href="{{path('group_member',{id:groupinfo.id})}}">小组成员</a></li>
        {% if is_groupmember==2 or is_granted('ROLE_ADMIN') or is_groupmember==3%}
          <li {% if groupNav=="setting" %}class="active" {% endif %}><a  href="{{path('group_set',{id:groupinfo.id})}}">小组设置</a></li>
        {% endif %}
      </ul>
      <h4 class="mtl">组长</h4>
      <div class="clearfix">
        <div class="grouplist"  style="width: 108px;">
          <a href="{{path('user_show',{id:owner_info.id})}}" title="{{owner_info.nickname}}"  >
            <img src="{{ filepath(owner_info.largeAvatar, 'avatar.png') }}" alt="{{owner_info.nickname}}" class="avatar-sm">
          </a>
          <p class="text-center"><a class="link-light" href="{{path('user_show',{id:owner_info.id})}}" title="{{owner_info.nickname}}">{{owner_info.nickname}}</a>
          </p>
        </div>
      </div>
      <h4 class="mtl">副组长</h4>
      <div class="clearfix">
        <form action="{{path('group_remove_admin',{id:groupinfo.id})}}" method="post" id="admin-form">
          {% if groupAdmin %}
            {% if is_groupmember==2 or is_granted('ROLE_ADMIN')  %}
              <button id="remove-admin-btn" type="button" class="btn btn-default btn-sm pull-right">撤消副组长</button>
            {% endif %}
            {% for member in groupAdmin %}
              <div class="grouplist"  style="width: 108px;">
                <p>{{ web_macro.user_avatar(usersLikeAdmin[member.userId] , '') }}</p>
                <p class="text-center">{{ web_macro.user_link(usersLikeAdmin[member.userId] , 'link-muted') }}</p>
                {% if is_groupmember==2 or is_granted('ROLE_ADMIN') %}
                  <input type="checkbox" value="{{member.userId}}" name="adminId[]"class="checkboxs">
                {% endif %}
                <br>
              </div>
              
            {% endfor %}
          {% else %}
            <p><sapn class="text-muted">还没有副组长！</span></p>
          {% endif %}
        </form>
      </div>
      <div class="btn-group pull-right">
        {% if groupmember_info %}
          {% if is_groupmember==2 or is_granted('ROLE_ADMIN') or is_groupmember==3 %}
            <button  id="delete-btn" type="button" class="btn btn-default btn-sm ">踢出成员</button>
          {% endif %}
          {% if is_groupmember==2 or is_granted('ROLE_ADMIN') %}
            <button  id="set-admin-btn" type="button" class="btn btn-default btn-sm ">设置副组长</button>
            <input id="set-admin-url" type="hidden" value="{{path('group_set_admin',{id:groupinfo.id})}}">
          {% endif %}
        {% endif %}
      </div>
      <form action="{{path('group_member_delete',{id:groupinfo.id})}}" method="post" id="member-form" class="clearfix">
        <h4 class="mtl">组员</h4>
        {% if groupmember_info %}
          
          {% for member in groupmember_info %}
            <div class="grouplist" style="width: 108px;">
              <p>{{ web_macro.user_avatar(members[member.userId] , '') }}</p>
              <p class="text-center">{{ web_macro.user_link(members[member.userId] , 'link-light') }}</p>
              {% if is_groupmember==2 or is_granted('ROLE_ADMIN') or is_groupmember==3%}
                <input type="checkbox" value="{{member.userId}}" name="memberId[]"class="checkboxs">
              {% endif %}<br>
            </div>
          {% endfor %}
          
          {% if is_groupmember==2 or is_granted('ROLE_ADMIN') or is_groupmember==3 %}
            <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">
          {% endif %}
          
        {% else %}
          <p><sapn class="text-muted">还没有小组成员！</span></p>
        {% endif %}
      </form>
      <nav class="text-center">
        {{ web_macro.paginator(paginator) }}
      </nav>
    </div>
  </div>
{% endblock %}